Skip to content

Improved file ordering in session - #41

Merged
chris-adam merged 3 commits into
mainfrom
PARAF-413/file_ordering
Aug 19, 2026
Merged

Improved file ordering in session#41
chris-adam merged 3 commits into
mainfrom
PARAF-413/file_ordering

Conversation

@chris-adam

@chris-adam chris-adam commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Improved file ordering in sessions to preserve the order in which items were added.
    • Added reliable ordering support across different session contexts, including empty containers.
    • State help tooltips now display the refusing user and their comment.
  • Bug Fixes

    • Corrected file insertion behavior so existing items retain their expected positions.
  • Tests

    • Added coverage for item ordering and context handling.

@chris-adam
chris-adam marked this pull request as ready for review May 27, 2026 11:16
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: df349644-a98b-42ac-8819-e43a1af5c62c

📥 Commits

Reviewing files that changed from the base of the PR and between 7de6da0 and dfaacc9.

📒 Files selected for processing (2)
  • CHANGES.rst
  • src/imio/esign/utils.py

📝 Walkthrough

Walkthrough

This PR adds IItemOrderProvider and a default adapter that maps context item UIDs to positions. ZCML registers the adapter, session file insertion uses it, and tests cover populated and empty folders.

Changes

Item Ordering Adapter Pattern

Layer / File(s) Summary
Interface and adapter implementation
src/imio/esign/interfaces.py, src/imio/esign/adapters.py, src/imio/esign/configure.zcml
Defines the item-ordering contract, implements UID-to-index mapping, and registers the adapter for all contexts.
File session integration
src/imio/esign/utils.py
Uses getAdapter(context, IItemOrderProvider).get_item_order() when inserting session files.
Adapter tests
src/imio/esign/tests/test_adapters.py
Tests context UID adaptation and item ordering for populated and empty folders.
Release notes
CHANGES.rst
Records improved file ordering in sessions and state help tooltip content.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SessionInsertion
  participant ItemOrderAdapter
  participant Context
  SessionInsertion->>ItemOrderAdapter: Request item order
  ItemOrderAdapter->>Context: Enumerate items and read UIDs
  Context-->>ItemOrderAdapter: Ordered items
  ItemOrderAdapter-->>SessionInsertion: Return UID-to-index mapping
Loading

Possibly related PRs

Suggested reviewers: sgeulette, gbastien

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: improved file ordering in the session.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PARAF-413/file_ordering

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/imio/esign/tests/test_adapters.py (1)

31-33: ⚡ Quick win

Assert complete UID→index mapping equality.

This loop validates expected keys but not unexpected extra entries in order. Build the expected mapping and assert full dict equality.

Proposed test tightening
-        children = list(folder.values())
-        for idx, child in enumerate(children):
-            self.assertEqual(order[child.UID()], idx)
+        children = list(folder.values())
+        expected_order = {child.UID(): idx for idx, child in enumerate(children)}
+        self.assertEqual(order, expected_order)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/imio/esign/tests/test_adapters.py` around lines 31 - 33, The test
currently loops over children and asserts each child's UID maps to the expected
index but doesn't catch extra keys in order; instead, construct an expected
mapping from the actual children (e.g., expected = {child.UID(): idx for idx,
child in enumerate(list(folder.values()))}) and then assert equality between
expected and order (use assertEqual(expected, order)) so the test fails on both
missing and unexpected entries; update the code around the loop that references
children, folder.values(), order, and child.UID() accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/imio/esign/tests/test_adapters.py`:
- Around line 31-33: The test currently loops over children and asserts each
child's UID maps to the expected index but doesn't catch extra keys in order;
instead, construct an expected mapping from the actual children (e.g., expected
= {child.UID(): idx for idx, child in enumerate(list(folder.values()))}) and
then assert equality between expected and order (use assertEqual(expected,
order)) so the test fails on both missing and unexpected entries; update the
code around the loop that references children, folder.values(), order, and
child.UID() accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 40137db8-1a6a-45cf-9565-5de5da02c4d1

📥 Commits

Reviewing files that changed from the base of the PR and between 3e06631 and 05e6fab.

📒 Files selected for processing (6)
  • CHANGES.rst
  • src/imio/esign/adapters.py
  • src/imio/esign/configure.zcml
  • src/imio/esign/interfaces.py
  • src/imio/esign/tests/test_adapters.py
  • src/imio/esign/utils.py

@coveralls

coveralls commented May 27, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 32146829192

Coverage increased (+0.1%) to 86.842%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 9 of 9 lines across 3 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1444
Covered Lines: 1254
Line Coverage: 86.84%
Coverage Strength: 0.87 hits per line

💛 - Coveralls

@chris-adam
chris-adam requested review from gbastien and sgeulette May 27, 2026 11:22

@gbastien gbastien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Salut @chris-adam j'ai testé et surchargé pour afficher l'annexe principale générée puis les annexes "à signer" du point et çà fonctionne bien.
Juste en passant, je vois que tu ajoutes un test pour get_context_uid qui existait déjà mais pas testé, en lisant l'implémentation de get_context_uid çà m'a perturbé car très défensif et finalement pas nécessaire :-) Je ferais comme implémentation de get_context_uid: "return self.context.aq_parent.UID()" car c'est une annexe et dans Zope tu as d'office aq_parent et d'office aussi la fonction UID...
Pour moi çà peut être mergé (je vais merger le main pour màj la branche)

@chris-adam
chris-adam merged commit 60717eb into main Aug 19, 2026
0 of 5 checks passed
@chris-adam
chris-adam deleted the PARAF-413/file_ordering branch August 19, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants